import { CommonProps as BaseCommonProps } from './CommonProps';
import { IEditor } from '../../defines/application';

export const Properties: IEditor[] = [
  {
    field: 'name',
    text: 'Label',
    type: 'string',
    specialType: 'title'
  },
  {
    text: 'Other',
    type: 'group',
    data: [
      {
        field: 'required',
        text: 'Required',
        type: 'boolean'
      },
      {
        field: 'enableSearch',
        text: 'EnableSearch',
        type: 'boolean'
      }
    ]
  },
  {
    field: 'placeholder',
    text: 'Placeholder',
    type: 'string'
  },
  {
    field: 'useExternal',
    text: 'Options',
    type: 'options',
    data: {
      externalField: 'externalOption',
      field: 'options'
    }
  },
  // 高级设置
  {
    group: 'Advanced', // 分组 --- 高级设置 or 基础设置(默认)
    field: 'visibleConditions',
    text: 'Condition',
    type: 'Condition'
  }
];

export class CommonProps extends BaseCommonProps {
  public enableSearch = false;
  public useExternal = false;
  public externalOption?: {
    url: string;
    sign?: string;
    appKey?: string;
    formatVal?: any;
    searchData?: any;
    placeholder?: string;
    rows?: boolean;
    searchWithoutData?: boolean;
    enableLoadMore?: boolean; // 是否支持分页加载更多功能
  };
  public options: IOption[] = [];
  public placeholder = '请选择'; // 控件提示语
  public defaultValue?: any; // 默认值
  public notFoundContent?: string = '暂无数据';
  public tipText?: string;
  public showSearch?: boolean;
  public clickEffect?: () => void;

}
export interface IOption {
  value: string;
  text: string;
  disabled?: boolean;
}

export class CommonState {
  public options: IOption[] = [];
}
